#include "../inc/Ui/TwitterMyProfileForm.h"
#include "../inc/Model/TwitterMySnsGatewayManager.h"
#include "../inc/Ui/TwitterForm.h"
#include"../inc/Ui/FormManager.h"

using namespace Osp::Base;
using namespace Osp::Ui;
using namespace Osp::Ui::Controls;
int MyProfileForm::FormId = -1;

MyProfileForm::MyProfileForm(void) {
}

MyProfileForm::~MyProfileForm(void) {
}

bool MyProfileForm::Initialize() {
	Form::Construct(L"Twitter_MyProfileForm");

	return true;
}

result MyProfileForm::OnInitializing(void) {
	result r = E_SUCCESS;

	// TODO: Add your initialization code here
	pEditAreaProfile = static_cast<EditArea*> (GetControl(
			"IDC_EDITAREA_PROFILE"));
	this->SetSoftkeyActionId(SOFTKEY_1, ID_SOFTKEY_BACK);
	this->AddSoftkeyActionListener(SOFTKEY_1, *this);
	return r;
}

result MyProfileForm::OnTerminating(void) {
	result r = E_SUCCESS;

	// TODO: Add your termination code here

	return r;
}
void MyProfileForm::OnActionPerformed(const Osp::Ui::Control& source,
		int actionId) {
	FormManager *pFormManager = null;
	Form *pTwitterForm = null;
	FormManager::GetInstance(pFormManager);
	result r = pFormManager->GetForm(TwitterForm::GetFormId(), pTwitterForm);
	if (IsFailed(r)) {
		return;
	}
	MySnsGatewayManager
			*mySnsGatewayManager =
					(static_cast<TwitterForm*> (pTwitterForm))->GetSnsGatewayTwitterForm();
	switch (actionId) {
	case ID_SOFTKEY_BACK:
		mySnsGatewayManager->RequestActivities();
		pFormManager->SetCurrentForm(TwitterForm::GetFormId());
		break;
	default:
		break;
	}
}

void MyProfileForm::SetMyProfileToEditArea(String myProfile, String location) {
	if (myProfile.GetLength() > 0) {
		pEditAreaProfile->SetText(myProfile);
		pEditAreaProfile->RequestRedraw(true);
	}
	else
	{
		MessageBox msg;
			msg.Construct("Chào bạn ", "Việc lấy thông tin cá nhân thất bại", MSGBOX_STYLE_OK, 3000);
			int i = 0;
			msg.ShowAndWait(i);

	}
}
void MyProfileForm::ThongBaoLoi(String value) {
	MessageBox msg;
	msg.Construct("Chào bạn ", value, MSGBOX_STYLE_OK, 3000);
	int i = 0;
	msg.ShowAndWait(i);

}
